Aql queries

Basic Model Queries

Description Workbench Selection Syntax
Current Element Model Element aql:self
Container of current element A model element aql:self. eContainer()
Type of an element A model element aql:self. eClass()
Total number of elements in a model A model element aql:self. ancestors()->last().eAllContents()->size()
Total number of sub-elements A model element aql:self. eAllContents()->size()


Diagram Queries

Description Workbench Selection Syntax
Semantic element associated to a graphical element A diagram / A diagram element aql:self. target
aird file (non fragmented model) A diagram aql:((self.makeUnion(self, self.eInverse(''))).ancestors()->select(ancestor | ancestor.eClass().name = 'DAnalysis')->asSet())
All aird files (fragmented model) A diagram aql: self.getAllDAnalysis()
All diagrams A diagram aql: self.getAllDAnalysis(). ownedViews.ownedRepresentationDescriptors
Number of diagrams A diagram aql: self.getAllDAnalysis(). ownedViews.ownedRepresentationDescriptors->size()
All diagrams from kind "Logical Data Flow" A diagram aql: self.getAllDAnalysis(). ownedViews.ownedRepresentationDescriptors->select(x | x.description.name.startsWith('Logical Data Flow Blank'))
All diagrams except kind "Scenario" A diagram aql: self.getAllDAnalysis(). ownedViews.ownedRepresentationDescriptors->select(x | x.description.name.endsWith('Scenario') = false)
List of different viewpoints A diagram aql: self.getAllDAnalysis(). ownedViews.viewpoint->asSet()
Number of graphical elements in all diagrams A diagram aql: self.getAllDAnalysis(). ownedViews.ownedRepresentationDescriptors.representation.diagramElements->size()
Number of graphical elements in all diagrams (including technical elements like style, color…) A diagram aql: self.getAllDAnalysis(). ownedViews.ownedRepresentationDescriptors.representation.eAllContents()->size()

Searching Strings

Description Workbench Selection Syntax
All element containing the "TODO" string in their 'Name' property A model element aql:self.eAllContents()-> select(eAllContent | eAllContent.name.matches('.*TODO.*'))
All element containing the "TODO" string in their 'Summary' property A model element aql:self.eAllContents()-> select(eAllContent | eAllContent.summary.matches('.*TODO.*'))
All element containing the "TODO" string in their 'Description' property A model element aql:self.eAllContents()-> select(eAllContent | eAllContent.description.matches('.*TODO.*'))
All diagrams containing a note containing the "TODO" string A diagram aql: self.getAllDAnalysis().ownedViews.ownedRepresentationDescriptors. representation->select(x | x.eInverse('element')->filter(notation::Diagram).eAllContents(notation::Node)->select(x | x.type = 'Note' and x.description.contains('TODO')))
Number of diagrams containing a note containing the "TODO" string A diagram aql: self.getAllDAnalysis().ownedViews.ownedRepresentationDescriptors. representation->select(x | x.eInverse('element')->filter(notation::Diagram).eAllContents(notation::Node)->select(x | x.type = 'Note' and x.description.contains('TODO')))->size()

Requirements

Description Workbench Selection Syntax
Query to retrieve the list of non-allocated requirements Requirement Package aql:self. eAllContents()->select(x | x.getRelatedCapellaElements()->isEmpty())

Model Navigation Examples

Description Workbench Selection Syntax
List of functions allocated to a component Any Component aql:self.allocatedFunctions
List of sub logical components Any Logical Component aql:self.subLogicalComponents
List of all functions

- having more than 3 ports - allocated to one given component - Which name starts with "Store"

Any Component aql:self.allocatedFunctions->select(allocatedFunction | allocatedFunction.name.startsWith('Store') and allocatedFunction.eAllContents()->filter(fa::FunctionPort)->size() > 3)

Metrics

Description Workbench Selection Syntax
Number of YYYY::XXXX owned by the selected element, where XXXX is the type of a model element (aql:self.eClass() ) and YYYY the last term of its package A model element aql:self.eAllContents(YYYY::XXXX)->size()
Number of Operational Activities OperationalAnalysis aql:self.eAllContents(oa::OperationalActivity)->size()
Number of Operational Interactions OperationalAnalysis aql:self.eAllContents(fa::FunctionalExchange)->size()
Number of Exchange Items in OA OperationalAnalysis aql:self.eAllContents(modellingcore::AbstractExchangeItem)->size()
Number of Types (Classes, Datatypes) in OA OperationalAnalysis aql:self.eAllContents(datatype::DataType)->size()
Number of Classes in OA OperationalAnalysis

aql:self.eAllContents(information::Class)->size()

Number of States or Modes in OA OperationalAnalysis aql:(self.eAllContents()->filter(capellacommon::State) - self.eAllContents()->filter(capellacommon::Mode))->size()
Number of Operational Entities OperationalAnalysis aql:(self.eAllContents(oa::Entity)->select(e | not e.isActor()))->size()
Number of Operational Actors OperationalAnalysis aql:(self.eAllContents(oa::Entity)->select(e | e.isActor()))->size()
Number of Operational Roles OperationalAnalysis aql:self.eAllContents(oa::Role)->size()
Number of Communication Means OperationalAnalysis aql:self.eAllContents(oa::CommunicationMean)->size()
Number of System Functions SystemAnalysis aql:self.eAllContents(ctx::SystemFunction)->size()
Number of Functional Exchanges in SA SystemAnalysis aql:self.eAllContents(fa::FunctionalExchange)->size()
Number of Function Ports in SA SystemAnalysis aql:self.eAllContents()->filter(fa::FunctionPort)->size()
Number of System Actors SystemAnalysis aql:(self.eAllContents(ctx::SystemComponent)->select(c | c.isActor()))->size()
Number of Functional Chains in SA SystemAnalysis aql:self.eAllContents(fa::FunctionalChain)->size()
Number of Scenarios in SA SystemAnalysis aql:self.eAllContents(interaction::Scenario)->size()
Number of Behaviour Components in PA PhysicalArchitecture aql:self.eAllContents(pa::PhysicalComponent)->select(eAllContent | eAllContent.nature = pa::PhysicalComponentNature::BEHAVIOR)->size()
Number of Implementation PC (nodes) in PA PhysicalArchitecture aql:self.eAllContents(pa::PhysicalComponent)->select(eAllContent | eAllContent.nature = pa::PhysicalComponentNature::NODE)->size()
Number of Physical Links PhysicalArchitecture aql:self.eAllContents(cs::PhysicalLink)->size()
Number of Physical Ports PhysicalArchitecture aql:self.eAllContents(cs::PhysicalPort)->size()

Advanced Queries

With Aql, you can navigate in elements following references and attributes: aql:self.outgoing on a SystemFunction will retrieve outgoing functional exchanges:



There is many way to retrieve which references to use for an element. These references ca be used in a request like the above outgoing reference. For instance, you can retrieve references with Aql using the following request: aql:self.eClass().eAllReferences (or self.eClass().eAllAttributes to retrieve attributes)



One easiest way to retrieve references or attributes is to open the Properties View and go the Expert tab then choose relevant references/attributes for your query



You just have to write the reference name in a camelCaseFormat to use it with Aql (e.g. Available In States => availableInStates) or in some case with the corresponding getter function